home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000076_icon-group-sender _Tue Sep 23 08:01:38 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
4KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id IAA11882
for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Tue, 23 Sep 1997 08:01:37 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA09017; Tue, 23 Sep 1997 08:01:36 -0700
To: icon-group@cs.arizona.edu
Date: Tue, 23 Sep 1997 18:12:03 +1000
From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
Message-Id: <Stuart.Robinson-2309971812040001@asianstmg-221.anu.edu.au>
Organization: ANU
Sender: icon-group-request@cs.arizona.edu
Subject: another program with problems
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Hello. I'm sorry to keep posting my programs to comp.lang.icon for
editorial comments, but I have no local Icon support. Anyhow, I have a
program that is producing output that I wouldn't expect, given the input.
Here's the program:
################################################################################
## Program modified 22 Sept 1997, SPR--total_no added
## Program finished 13 May 97, SPR
## program designed to tally the number of {S's, {A's, and {O's in a text
################################################################################
procedure main()
chars := &letters ++ &digits ++ '{.*[]?' #valid characters
total_no := 0
noS := 0
noA := 0
noO := 0
none := 0
while line := read() do #line = line of text
{
total_no +:= 1 #increment total_no by 1
line ? #scan line
{
while tab(upto(chars)) do #look for valid character
{
word := tab(many(chars)) #word = valid character through
next invalid character
word ? #scan word
{
while tab(upto("{") +1) do #move just past bracket (will
fail if there is none)
{
wordfrag := move(1) #wordfrag = one character past bracket
case wordfrag of #if wordfrag is
{
"S" : noS +:= 1 #S, then increment noS by 1
"A" : noA +:= 1 #A, then increment noA by 1
"O" : noO +:= 1 #O, then increment noO by 1
default : none +:= 1 #none of the above letters,
#then increment none by 1
}
}
}
}
}
}
write( "Total No. of Clauses: " || total_no ) #writes total number of
clauses (total_no)
write( "Total No. of Nonverbal Clauses: " || none ) #writes total number
of clauses without S, A, or O
write( "Total No. of S's: " || noS ) #writes total number of S's (noS)
write( "Total No. of A's: " || noA ) #writes total number of A's (noA)
write( "Total No. of O's: " || noO ) #writes total number of O's (noO)
end
################################################################################
Here's the input:
{S
{A
{O
{S
{A
{O
{S
{A
{O
nonverbal
nonverbal
nonverbal
{
{
{
Given the program and the input, I would expect the following output:
Total No. of Clauses: 15
Total No. of Nonverbal Clauses: 3
Total No. of S's: 3
Total No. of A's: 3
Total No. of O's: 3
But instead I get this:
Total No. of Clauses: 15
Total No. of Nonverbal Clauses: 0
Total No. of S's: 3
Total No. of A's: 3
Total No. of O's: 6
It seems the lines with a single curly brackets are being treated as lines
with "{O". What gives?
Cheers,
Stuart
--
Stuart Robinson <Stuart.Robinson@no_spam!anu.edu.au>
The Australian National University
*TO REPLY, REMOVE "no_spam!" FROM E-MAIL ADDRESS GIVEN ABOVE